Optimal. Leaf size=123 \[ \frac {2 b^2 \left (3 a^2-2 b^2\right ) \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{a^3 \left (a^2-b^2\right )^{3/2}}+\frac {2 b \tanh ^{-1}(\cos (x))}{a^3}-\frac {\left (a^2-2 b^2\right ) \cot (x)}{a^2 \left (a^2-b^2\right )}-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.24, antiderivative size = 123, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 7, integrand size = 13, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.538, Rules used = {2881, 3134,
3080, 3855, 2739, 632, 210} \begin {gather*} \frac {2 b \tanh ^{-1}(\cos (x))}{a^3}-\frac {\left (a^2-2 b^2\right ) \cot (x)}{a^2 \left (a^2-b^2\right )}-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))}+\frac {2 b^2 \left (3 a^2-2 b^2\right ) \text {ArcTan}\left (\frac {a \tan \left (\frac {x}{2}\right )+b}{\sqrt {a^2-b^2}}\right )}{a^3 \left (a^2-b^2\right )^{3/2}} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 210
Rule 632
Rule 2739
Rule 2881
Rule 3080
Rule 3134
Rule 3855
Rubi steps
\begin {align*} \int \frac {\csc ^2(x)}{(a+b \sin (x))^2} \, dx &=-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))}+\frac {\int \frac {\csc ^2(x) \left (a^2-2 b^2-a b \sin (x)+b^2 \sin ^2(x)\right )}{a+b \sin (x)} \, dx}{a \left (a^2-b^2\right )}\\ &=-\frac {\left (a^2-2 b^2\right ) \cot (x)}{a^2 \left (a^2-b^2\right )}-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))}+\frac {\int \frac {\csc (x) \left (-2 b \left (a^2-b^2\right )+a b^2 \sin (x)\right )}{a+b \sin (x)} \, dx}{a^2 \left (a^2-b^2\right )}\\ &=-\frac {\left (a^2-2 b^2\right ) \cot (x)}{a^2 \left (a^2-b^2\right )}-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))}-\frac {(2 b) \int \csc (x) \, dx}{a^3}+\frac {\left (b^2 \left (3 a^2-2 b^2\right )\right ) \int \frac {1}{a+b \sin (x)} \, dx}{a^3 \left (a^2-b^2\right )}\\ &=\frac {2 b \tanh ^{-1}(\cos (x))}{a^3}-\frac {\left (a^2-2 b^2\right ) \cot (x)}{a^2 \left (a^2-b^2\right )}-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))}+\frac {\left (2 b^2 \left (3 a^2-2 b^2\right )\right ) \text {Subst}\left (\int \frac {1}{a+2 b x+a x^2} \, dx,x,\tan \left (\frac {x}{2}\right )\right )}{a^3 \left (a^2-b^2\right )}\\ &=\frac {2 b \tanh ^{-1}(\cos (x))}{a^3}-\frac {\left (a^2-2 b^2\right ) \cot (x)}{a^2 \left (a^2-b^2\right )}-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))}-\frac {\left (4 b^2 \left (3 a^2-2 b^2\right )\right ) \text {Subst}\left (\int \frac {1}{-4 \left (a^2-b^2\right )-x^2} \, dx,x,2 b+2 a \tan \left (\frac {x}{2}\right )\right )}{a^3 \left (a^2-b^2\right )}\\ &=\frac {2 b^2 \left (3 a^2-2 b^2\right ) \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{a^3 \left (a^2-b^2\right )^{3/2}}+\frac {2 b \tanh ^{-1}(\cos (x))}{a^3}-\frac {\left (a^2-2 b^2\right ) \cot (x)}{a^2 \left (a^2-b^2\right )}-\frac {b^2 \cot (x)}{a \left (a^2-b^2\right ) (a+b \sin (x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.49, size = 127, normalized size = 1.03 \begin {gather*} \frac {\frac {4 b^2 \left (3 a^2-2 b^2\right ) \tan ^{-1}\left (\frac {b+a \tan \left (\frac {x}{2}\right )}{\sqrt {a^2-b^2}}\right )}{\left (a^2-b^2\right )^{3/2}}-a \cot \left (\frac {x}{2}\right )+4 b \log \left (\cos \left (\frac {x}{2}\right )\right )-4 b \log \left (\sin \left (\frac {x}{2}\right )\right )+\frac {2 a b^3 \cos (x)}{(a-b) (a+b) (a+b \sin (x))}+a \tan \left (\frac {x}{2}\right )}{2 a^3} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.33, size = 144, normalized size = 1.17
method | result | size |
default | \(\frac {\tan \left (\frac {x}{2}\right )}{2 a^{2}}-\frac {1}{2 a^{2} \tan \left (\frac {x}{2}\right )}-\frac {2 b \ln \left (\tan \left (\frac {x}{2}\right )\right )}{a^{3}}+\frac {2 b^{2} \left (\frac {\frac {b^{2} \tan \left (\frac {x}{2}\right )}{a^{2}-b^{2}}+\frac {a b}{a^{2}-b^{2}}}{a \left (\tan ^{2}\left (\frac {x}{2}\right )\right )+2 b \tan \left (\frac {x}{2}\right )+a}+\frac {\left (3 a^{2}-2 b^{2}\right ) \arctan \left (\frac {2 a \tan \left (\frac {x}{2}\right )+2 b}{2 \sqrt {a^{2}-b^{2}}}\right )}{\left (a^{2}-b^{2}\right )^{\frac {3}{2}}}\right )}{a^{3}}\) | \(144\) |
risch | \(-\frac {2 i \left (2 a^{3} {\mathrm e}^{i x}-3 b^{2} a \,{\mathrm e}^{i x}-i a^{2} b \,{\mathrm e}^{2 i x}+2 i b^{3} {\mathrm e}^{2 i x}+i a^{2} b -2 i b^{3}+a \,b^{2} {\mathrm e}^{3 i x}\right )}{\left ({\mathrm e}^{2 i x}-1\right ) \left (a^{2}-b^{2}\right ) \left (-i b \,{\mathrm e}^{2 i x}+i b +2 a \,{\mathrm e}^{i x}\right ) a^{2}}+\frac {3 b^{2} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}+a^{2}-b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) a}-\frac {2 b^{4} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}+a^{2}-b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) a^{3}}-\frac {3 b^{2} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}-a^{2}+b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) a}+\frac {2 b^{4} \ln \left ({\mathrm e}^{i x}+\frac {i a \sqrt {-a^{2}+b^{2}}-a^{2}+b^{2}}{b \sqrt {-a^{2}+b^{2}}}\right )}{\sqrt {-a^{2}+b^{2}}\, \left (a +b \right ) \left (a -b \right ) a^{3}}+\frac {2 b \ln \left ({\mathrm e}^{i x}+1\right )}{a^{3}}-\frac {2 b \ln \left ({\mathrm e}^{i x}-1\right )}{a^{3}}\) | \(456\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 359 vs.
\(2 (117) = 234\).
time = 0.68, size = 784, normalized size = 6.37 \begin {gather*} \left [-\frac {2 \, {\left (a^{5} b - 3 \, a^{3} b^{3} + 2 \, a b^{5}\right )} \cos \left (x\right ) \sin \left (x\right ) + {\left (3 \, a^{2} b^{3} - 2 \, b^{5} - {\left (3 \, a^{2} b^{3} - 2 \, b^{5}\right )} \cos \left (x\right )^{2} + {\left (3 \, a^{3} b^{2} - 2 \, a b^{4}\right )} \sin \left (x\right )\right )} \sqrt {-a^{2} + b^{2}} \log \left (\frac {{\left (2 \, a^{2} - b^{2}\right )} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2} + 2 \, {\left (a \cos \left (x\right ) \sin \left (x\right ) + b \cos \left (x\right )\right )} \sqrt {-a^{2} + b^{2}}}{b^{2} \cos \left (x\right )^{2} - 2 \, a b \sin \left (x\right ) - a^{2} - b^{2}}\right ) + 2 \, {\left (a^{6} - 2 \, a^{4} b^{2} + a^{2} b^{4}\right )} \cos \left (x\right ) - 2 \, {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6} - {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6}\right )} \cos \left (x\right )^{2} + {\left (a^{5} b - 2 \, a^{3} b^{3} + a b^{5}\right )} \sin \left (x\right )\right )} \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) + 2 \, {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6} - {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6}\right )} \cos \left (x\right )^{2} + {\left (a^{5} b - 2 \, a^{3} b^{3} + a b^{5}\right )} \sin \left (x\right )\right )} \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right )}{2 \, {\left (a^{7} b - 2 \, a^{5} b^{3} + a^{3} b^{5} - {\left (a^{7} b - 2 \, a^{5} b^{3} + a^{3} b^{5}\right )} \cos \left (x\right )^{2} + {\left (a^{8} - 2 \, a^{6} b^{2} + a^{4} b^{4}\right )} \sin \left (x\right )\right )}}, -\frac {{\left (a^{5} b - 3 \, a^{3} b^{3} + 2 \, a b^{5}\right )} \cos \left (x\right ) \sin \left (x\right ) + {\left (3 \, a^{2} b^{3} - 2 \, b^{5} - {\left (3 \, a^{2} b^{3} - 2 \, b^{5}\right )} \cos \left (x\right )^{2} + {\left (3 \, a^{3} b^{2} - 2 \, a b^{4}\right )} \sin \left (x\right )\right )} \sqrt {a^{2} - b^{2}} \arctan \left (-\frac {a \sin \left (x\right ) + b}{\sqrt {a^{2} - b^{2}} \cos \left (x\right )}\right ) + {\left (a^{6} - 2 \, a^{4} b^{2} + a^{2} b^{4}\right )} \cos \left (x\right ) - {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6} - {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6}\right )} \cos \left (x\right )^{2} + {\left (a^{5} b - 2 \, a^{3} b^{3} + a b^{5}\right )} \sin \left (x\right )\right )} \log \left (\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right ) + {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6} - {\left (a^{4} b^{2} - 2 \, a^{2} b^{4} + b^{6}\right )} \cos \left (x\right )^{2} + {\left (a^{5} b - 2 \, a^{3} b^{3} + a b^{5}\right )} \sin \left (x\right )\right )} \log \left (-\frac {1}{2} \, \cos \left (x\right ) + \frac {1}{2}\right )}{a^{7} b - 2 \, a^{5} b^{3} + a^{3} b^{5} - {\left (a^{7} b - 2 \, a^{5} b^{3} + a^{3} b^{5}\right )} \cos \left (x\right )^{2} + {\left (a^{8} - 2 \, a^{6} b^{2} + a^{4} b^{4}\right )} \sin \left (x\right )}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \frac {\csc ^{2}{\left (x \right )}}{\left (a + b \sin {\left (x \right )}\right )^{2}}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [A]
time = 0.43, size = 234, normalized size = 1.90 \begin {gather*} \frac {2 \, {\left (3 \, a^{2} b^{2} - 2 \, b^{4}\right )} {\left (\pi \left \lfloor \frac {x}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (a\right ) + \arctan \left (\frac {a \tan \left (\frac {1}{2} \, x\right ) + b}{\sqrt {a^{2} - b^{2}}}\right )\right )}}{{\left (a^{5} - a^{3} b^{2}\right )} \sqrt {a^{2} - b^{2}}} + \frac {4 \, a^{3} b \tan \left (\frac {1}{2} \, x\right )^{3} - 4 \, a b^{3} \tan \left (\frac {1}{2} \, x\right )^{3} - 3 \, a^{4} \tan \left (\frac {1}{2} \, x\right )^{2} + 11 \, a^{2} b^{2} \tan \left (\frac {1}{2} \, x\right )^{2} + 4 \, b^{4} \tan \left (\frac {1}{2} \, x\right )^{2} - 2 \, a^{3} b \tan \left (\frac {1}{2} \, x\right ) + 14 \, a b^{3} \tan \left (\frac {1}{2} \, x\right ) - 3 \, a^{4} + 3 \, a^{2} b^{2}}{6 \, {\left (a^{5} - a^{3} b^{2}\right )} {\left (a \tan \left (\frac {1}{2} \, x\right )^{3} + 2 \, b \tan \left (\frac {1}{2} \, x\right )^{2} + a \tan \left (\frac {1}{2} \, x\right )\right )}} - \frac {2 \, b \log \left ({\left | \tan \left (\frac {1}{2} \, x\right ) \right |}\right )}{a^{3}} + \frac {\tan \left (\frac {1}{2} \, x\right )}{2 \, a^{2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 7.63, size = 1471, normalized size = 11.96 \begin {gather*} \frac {\mathrm {tan}\left (\frac {x}{2}\right )}{2\,a^2}-\frac {a-\frac {{\mathrm {tan}\left (\frac {x}{2}\right )}^2\,\left (-a^4+a^2\,b^2+4\,b^4\right )}{a\,\left (a^2-b^2\right )}+\frac {2\,b\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (a^2-3\,b^2\right )}{a^2-b^2}}{2\,a^3\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3+2\,a^3\,\mathrm {tan}\left (\frac {x}{2}\right )+4\,b\,a^2\,{\mathrm {tan}\left (\frac {x}{2}\right )}^2}-\frac {2\,b\,\ln \left (\mathrm {tan}\left (\frac {x}{2}\right )\right )}{a^3}-\frac {b^2\,\mathrm {atan}\left (\frac {\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (-2\,a^7\,b+14\,a^5\,b^3-20\,a^3\,b^5+8\,a\,b^7\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}-\frac {2\,\left (4\,a^3\,b^4-5\,a^5\,b^2\right )}{a^6-a^4\,b^2}+\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\left (a^8\,b-a^6\,b^3\right )}{a^6-a^4\,b^2}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a^{10}-10\,a^8\,b^2+11\,a^6\,b^4-4\,a^4\,b^6\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}\right )}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}\right )\,1{}\mathrm {i}}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}-\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\left (4\,a^3\,b^4-5\,a^5\,b^2\right )}{a^6-a^4\,b^2}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (-2\,a^7\,b+14\,a^5\,b^3-20\,a^3\,b^5+8\,a\,b^7\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}+\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\left (a^8\,b-a^6\,b^3\right )}{a^6-a^4\,b^2}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a^{10}-10\,a^8\,b^2+11\,a^6\,b^4-4\,a^4\,b^6\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}\right )}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}\right )\,1{}\mathrm {i}}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}}{\frac {4\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (4\,b^6-6\,a^2\,b^4\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}-\frac {4\,\left (4\,b^5-6\,a^2\,b^3\right )}{a^6-a^4\,b^2}+\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (-2\,a^7\,b+14\,a^5\,b^3-20\,a^3\,b^5+8\,a\,b^7\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}-\frac {2\,\left (4\,a^3\,b^4-5\,a^5\,b^2\right )}{a^6-a^4\,b^2}+\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\left (a^8\,b-a^6\,b^3\right )}{a^6-a^4\,b^2}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a^{10}-10\,a^8\,b^2+11\,a^6\,b^4-4\,a^4\,b^6\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}\right )}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}\right )}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}+\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\left (4\,a^3\,b^4-5\,a^5\,b^2\right )}{a^6-a^4\,b^2}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (-2\,a^7\,b+14\,a^5\,b^3-20\,a^3\,b^5+8\,a\,b^7\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}+\frac {b^2\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,\left (\frac {2\,\left (a^8\,b-a^6\,b^3\right )}{a^6-a^4\,b^2}-\frac {2\,\mathrm {tan}\left (\frac {x}{2}\right )\,\left (3\,a^{10}-10\,a^8\,b^2+11\,a^6\,b^4-4\,a^4\,b^6\right )}{a^7-2\,a^5\,b^2+a^3\,b^4}\right )}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}\right )}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6}}\right )\,\left (3\,a^2-2\,b^2\right )\,\sqrt {-{\left (a+b\right )}^3\,{\left (a-b\right )}^3}\,2{}\mathrm {i}}{a^9-3\,a^7\,b^2+3\,a^5\,b^4-a^3\,b^6} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________